package com.lehecai.core.api.openapi;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.lehecai.core.YesNoStatus;
import com.lehecai.core.util.CoreDateUtils;
/**
 * 2013-7-2
 * @author likunpeng
 * 充值文案信息
 */
public class RechargeCopywriter implements Serializable {

	private static final long serialVersionUID = 1L;
	
	public static final String ORDER_ID = "id";
	public static final String ORDER_ADD_TIME = "time_add";
	public static final String ORDER_UPDATE_TIME = "update_time";
	public static final String ORDER_RECHARGE_TYPE = "recharge_type";
	public static final String QUERY_STATUS = "status";
	public static final String QUERY_DOCNAME = "desc_name";
	public static final String QUERY_RECHARGE_TYPE_NAME = "recharge_type_name";
	public static final String QUERY_DOC_POSITION = "desc_site";
	public static final String QUERY_RECHARGE_CONTENT = "recharge_content";
	public static final String MAX_AMOUNT = "max_amount";
	public static final String MIN_AMOUNT = "min_amount";
	
	private Long id;              //自增的序号
	private Long num;             //充值类型编号
	private String docName;            //文案的名字
	private String rechargeTypeName;   //充值类型名称
	private String rechargeContent;   //充值文案内容
	private YesNoStatus status;       //状态
	private DocPosition docPosition;  //文案的位置
	private Date addTime;             //新增时间
	private Date updateTime;         //更新时间
	private String queryStr;
	private String queryOrder;
	private Integer isValid;
	private Integer docPlace;
	private Integer maxAmount;
	private Integer minAmount;
	
	public static RechargeCopywriter convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		RechargeCopywriter rechargeCopywriter = new RechargeCopywriter();
		rechargeCopywriter.setId(new Long(object.getInt("id")));
		rechargeCopywriter.setNum(new Long(object.getInt("recharge_type")));
		rechargeCopywriter.setStatus(YesNoStatus.getItem(object.getInt("status")));
		rechargeCopywriter.setDocName(object.getString("desc_name"));
		rechargeCopywriter.setDocPosition(DocPosition.getItem(object.getInt("desc_site")));
		rechargeCopywriter.setRechargeTypeName(object.getString("recharge_type_name"));
		rechargeCopywriter.setRechargeContent(object.getString("recharge_content"));
		rechargeCopywriter.setAddTime(CoreDateUtils.parseDate(object.getString("time_add"), "yyyy-MM-dd HH:mm:ss"));
		if ("0000-00-00 00:00:00".equals(object.getString("update_time"))) {
			rechargeCopywriter.setUpdateTime(null);
		} else {
			rechargeCopywriter.setUpdateTime(CoreDateUtils.parseDate(object.getString("update_time"), "yyyy-MM-dd HH:mm:ss"));
		}
		rechargeCopywriter.setMaxAmount(object.getInt("max_amount"));
		rechargeCopywriter.setMinAmount(object.getInt("min_amount"));
		return rechargeCopywriter;
	}
	  
	public static List<RechargeCopywriter> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<RechargeCopywriter> list = new ArrayList<RechargeCopywriter>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDocName() {
		return docName;
	}

	public void setDocName(String docName) {
		this.docName = docName;
	}

	public String getRechargeTypeName() {
		return rechargeTypeName;
	}

	public void setRechargeTypeName(String rechargeTypeName) {
		this.rechargeTypeName = rechargeTypeName;
	}

	public YesNoStatus getStatus() {
		return status;
	}

	public void setStatus(YesNoStatus status) {
		this.status = status;
	}

	public DocPosition getDocPosition() {
		return docPosition;
	}

	public void setDocPosition(DocPosition docPosition) {
		this.docPosition = docPosition;
	}
	
	public Long getNum() {
		return num;
	}

	public void setNum(Long num) {
		this.num = num;
	}

	public String getRechargeContent() {
		return rechargeContent;
	}

	public void setRechargeContent(String rechargeContent) {
		this.rechargeContent = rechargeContent;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getQueryStr() {
		return queryStr;
	}

	public void setQueryStr(String queryStr) {
		this.queryStr = queryStr;
	}

	public String getQueryOrder() {
		return queryOrder;
	}

	public void setQueryOrder(String queryOrder) {
		this.queryOrder = queryOrder;
	}

	public void setIsValid(Integer isValid) {
		this.isValid = isValid;
	}

	public Integer getIsValid() {
		return isValid;
	}

	public void setDocPlace(Integer docPlace) {
		this.docPlace = docPlace;
	}

	public Integer getDocPlace() {
		return docPlace;
	}

	public void setMaxAmount(Integer maxAmount) {
		this.maxAmount = maxAmount;
	}

	public Integer getMaxAmount() {
		return maxAmount;
	}

	public void setMinAmount(Integer minAmount) {
		this.minAmount = minAmount;
	}

	public Integer getMinAmount() {
		return minAmount;
	}
}
